from flask import Flask,request,render_template,abort

app = Flask(__name__)

@app.route("/register",methods=["GET","POST"])
def register():
    if request.method == "GET":
        return render_template("register.html")
    elif request.method == "POST":
        username = request.form.get("username")
        password = request.form.get("password")
        password2 = request.form.get("password2")
        print(username)
        print(password)
        print(password2)
        if ("张三" == username):
            abort(405)
            return None
        else:
            return "注册成功"

@app.errorhandler(405)
def handler_405_error(err):
    return render_template("405.html")


if __name__ == '__main__':
    app.run()